﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace TankBattle.Models
{
    public class SmartAutoTank: AutoTank
    {
        #region variable
        protected bool _smartMove;
        protected int smartFlag;
        #endregion 

        #region Contruction 
        public SmartAutoTank()
        {
        }
        public SmartAutoTank(Texture2D texture, Vector2 position, int flag)
            :base (texture, position, flag)
        {
            smartFlag = flag;
        }
        #endregion 

        #region Poperties
        #endregion

        #region Main Function 
        public override bool TestMove(List<GameObject> Obstruction)
        {
            if (preFlag != flag) { _smartMove = true; }
            else if (smartFlag != flag) { _smartMove = false; }
            int temp = Obstruction.Count - 1;
            if (_smartMove)
            {
                if (timeCount > shootDelay /3) timeCount = shootDelay;
                if (Obstruction[temp].Position.X > position.X) flag = Constant.MOVE_RIGHT;
                else if (Obstruction[temp].Position.X < position.X) flag = Constant.MOVE_LEFT;
                else if (Obstruction[temp].Position.Y > position.Y) flag = Constant.MOVE_DOWN;
                else flag = Constant.MOVE_UP;
            }
            smartFlag = flag;
            return base.TestMove(Obstruction);
        }
        #endregion 

        #region Other Function 
        protected override void Intallization(Texture2D texture, Vector2 position, int width, int height)
        {
            _smartMove = true;
            base.Intallization(texture, position, width, height);
        }
        #endregion 
    }
}
